home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / seicross.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  5KB  |  173 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12.  
  13.  
  14. unsigned char *seicross_row_scroll;
  15.  
  16.  
  17.  
  18.  
  19. /***************************************************************************
  20.  
  21.   Convert the color PROMs into a more useable format.
  22.  
  23.   Seicross has two 32x8 palette PROMs, connected to the RGB output this way:
  24.  
  25.   bit 7 -- 220 ohm resistor  -- BLUE
  26.         -- 470 ohm resistor  -- BLUE
  27.         -- 220 ohm resistor  -- GREEN
  28.         -- 470 ohm resistor  -- GREEN
  29.         -- 1  kohm resistor  -- GREEN
  30.         -- 220 ohm resistor  -- RED
  31.         -- 470 ohm resistor  -- RED
  32.   bit 0 -- 1  kohm resistor  -- RED
  33.  
  34. ***************************************************************************/
  35. void seicross_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  36. {
  37.     int i;
  38.     #define TOTAL_COLORS(gfxn) (Machine->gfx[gfxn]->total_colors * Machine->gfx[gfxn]->color_granularity)
  39.     #define COLOR(gfxn,offs) (colortable[Machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
  40.  
  41.  
  42.     for (i = 0;i < Machine->drv->total_colors;i++)
  43.     {
  44.         int bit0,bit1,bit2;
  45.  
  46.  
  47.         /* red component */
  48.         bit0 = (*color_prom >> 0) & 0x01;
  49.         bit1 = (*color_prom >> 1) & 0x01;
  50.         bit2 = (*color_prom >> 2) & 0x01;
  51.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  52.         /* green component */
  53.         bit0 = (*color_prom >> 3) & 0x01;
  54.         bit1 = (*color_prom >> 4) & 0x01;
  55.         bit2 = (*color_prom >> 5) & 0x01;
  56.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  57.         /* blue component */
  58.         bit0 = 0;
  59.         bit1 = (*color_prom >> 6) & 0x01;
  60.         bit2 = (*color_prom >> 7) & 0x01;
  61.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  62.  
  63.         color_prom++;
  64.     }
  65. }
  66.  
  67.  
  68.  
  69. WRITE_HANDLER( seicross_colorram_w )
  70. {
  71.     if (colorram[offset] != data)
  72.     {
  73.         /* bit 5 of the address is not used for color memory. There is just */
  74.         /* 512k of memory; every two consecutive rows share the same memory */
  75.         /* region. */
  76.         offset &= 0xffdf;
  77.  
  78.         dirtybuffer[offset] = 1;
  79.         dirtybuffer[offset + 0x20] = 1;
  80.  
  81.         colorram[offset] = data;
  82.         colorram[offset + 0x20] = data;
  83.     }
  84. }
  85.  
  86.  
  87.  
  88.  
  89. /***************************************************************************
  90.  
  91.   Draw the game screen in the given osd_bitmap.
  92.   Do NOT call osd_update_display() from this function, it will be called by
  93.   the main emulation engine.
  94.  
  95. ***************************************************************************/
  96. void seicross_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  97. {
  98.     int offs,x;
  99.  
  100.     /* for every character in the Video RAM, check if it has been modified */
  101.     /* since last time and update it accordingly. */
  102.  
  103.     for (offs = videoram_size - 1;offs >= 0;offs--)
  104.     {
  105.         if (dirtybuffer[offs])
  106.         {
  107.             int sx,sy;
  108.  
  109.  
  110.             dirtybuffer[offs] = 0;
  111.  
  112.             sx = offs % 32;
  113.             sy = offs / 32;
  114.  
  115.             drawgfx(tmpbitmap,Machine->gfx[0],
  116.                     videoram[offs] + ((colorram[offs] & 0x10) << 4),
  117.                     colorram[offs] & 0x0f,
  118.                     colorram[offs] & 0x40,colorram[offs] & 0x80,
  119.                     8*sx,8*sy,
  120.                     0,TRANSPARENCY_NONE,0);
  121.         }
  122.     }
  123.  
  124.  
  125.     /* copy the temporary bitmap to the screen */
  126.     {
  127.         int scroll[32];
  128.  
  129.  
  130.         for (offs = 0;offs < 32;offs++)
  131.             scroll[offs] = -seicross_row_scroll[offs];
  132.  
  133.         copyscrollbitmap(bitmap,tmpbitmap,0,0,32,scroll,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  134.     }
  135.  
  136.     /* draw sprites */
  137.     for (offs = spriteram_size - 4;offs >= 0;offs -= 4)
  138.     {
  139.         x=spriteram[offs + 3];
  140.         drawgfx(bitmap,Machine->gfx[1],
  141.                 (spriteram[offs] & 0x3f) + ((spriteram[offs + 1] & 0x10) << 2) + 128,
  142.                 spriteram[offs + 1] & 0x0f,
  143.                 spriteram[offs] & 0x40,spriteram[offs] & 0x80,
  144.                 x,240-spriteram[offs + 2],
  145.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  146.         if(x>0xf0)
  147.             drawgfx(bitmap,Machine->gfx[1],
  148.                     (spriteram[offs] & 0x3f) + ((spriteram[offs + 1] & 0x10) << 2) + 128,
  149.                     spriteram[offs + 1] & 0x0f,
  150.                     spriteram[offs] & 0x40,spriteram[offs] & 0x80,
  151.                     x-256,240-spriteram[offs + 2],
  152.                     &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  153.     }
  154.  
  155.     for (offs = spriteram_2_size - 4;offs >= 0;offs -= 4)
  156.     {
  157.         x=spriteram_2[offs + 3];
  158.         drawgfx(bitmap,Machine->gfx[1],
  159.                 (spriteram_2[offs] & 0x3f) + ((spriteram_2[offs + 1] & 0x10) << 2),
  160.                 spriteram_2[offs + 1] & 0x0f,
  161.                 spriteram_2[offs] & 0x40,spriteram_2[offs] & 0x80,
  162.                 x,240-spriteram_2[offs + 2],
  163.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  164.         if(x>0xf0)
  165.             drawgfx(bitmap,Machine->gfx[1],
  166.                     (spriteram_2[offs] & 0x3f) + ((spriteram_2[offs + 1] & 0x10) << 2),
  167.                     spriteram_2[offs + 1] & 0x0f,
  168.                     spriteram_2[offs] & 0x40,spriteram_2[offs] & 0x80,
  169.                     x-256,240-spriteram_2[offs + 2],
  170.                     &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  171.     }
  172. }
  173.